package cn.yyt.yytravel.scene.controller;

import cn.yyt.yytravel.scene.pojo.AreaQuery;
import cn.yyt.yytravel.scene.pojo.AreaSaveParam;
import cn.yyt.yytravel.scene.pojo.AreaVO;
import cn.yyt.yytravel.scene.service.AreaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.yyt.yytravel.base.response.JsonResult;

import java.util.List;
@Slf4j
@RestController
@RequestMapping("/yyt/scene/")
public class AreaController {
    @Autowired
    private AreaService areaService;
    @GetMapping("select")
    public JsonResult selectArea(AreaQuery areaQuery){
       List<AreaVO> list =areaService.selectArea(areaQuery);
       log.debug("结果{}",list);
       return JsonResult.ok(list);
    }


    @GetMapping("selectId/{id}")
    public JsonResult selectById(@PathVariable("id") Integer id){
        log.debug("id{}",id);
        List<AreaVO> list =areaService.selectAreaById(id);
        log.debug("结果{}",list);
        return JsonResult.ok(list);
    }
    @PostMapping("save")
   public JsonResult saveArea(AreaSaveParam areaSaveParam){
        log.debug("保存用户，areaSaveParam={}",areaSaveParam);
        areaService.saveArea(areaSaveParam);
        return JsonResult.ok();
   }
    @PostMapping("delete/{areaId}")
    public JsonResult deleteArea(@PathVariable("areaId") Long userId){
        log.debug("删除用户，userId={}",userId);
        areaService.deleteArea(userId);
        return JsonResult.ok();
    }








}
